﻿using System;
using Gp.AI;
using Gp.Scripts.Database;
using Sirenix.OdinInspector;

namespace Gp.Scripts.Data {
    public enum DefaultAIBrains {
        GenericUnit,
        RangedUnit,
        MeleeUnit,
    }
    
    
    [Serializable]
    public class UnitAIBrainWrapper {
        [LabelText("使用自定义")]
        public bool custom;

        
        [LabelText("基础预设"), HideIf("@custom")]
        public DefaultAIBrains defaultPresets = DefaultAIBrains.GenericUnit;
        
        
        [ShowIf("@custom")]
        [HideLabel]
        public UnitAIBrainPreset brainPreset;


        public UnitAIBrainPreset GetAIBrain() {
            if (custom && brainPreset != null) return brainPreset;
            var db = LevelObjectConfigDatabase.Instance;
            return defaultPresets switch {
                DefaultAIBrains.GenericUnit => db.defaultGeneric,
                DefaultAIBrains.RangedUnit => db.defaultRanged,
                DefaultAIBrains.MeleeUnit => db.defaultMelee,
                _ => throw new ArgumentOutOfRangeException()
            };
        }
    }
}